﻿
#include "zyCustomCtrol.h"

DarkMoonUI::zyCustomCtrol::zyCustomCtrol()
{
	SetMember(L"this", (LONG_PTR)this);
	m_obj->setWndProc(zyCustomCtrol_WndProc);
	m_obj->setDestroy(zyCustomCtrol_Destroy);
}
DarkMoonUI::zyCustomCtrol::~zyCustomCtrol()
{

}
void WINAPI DarkMoonUI::zyCustomCtrol::zyCustomCtrol_Destroy(zyObject* obj)
{
	zyCustomCtrol* zyb = (zyCustomCtrol*)obj->getPtrData(L"this");
	zyb->OnNCDestroy();
	zyCtrol::zyCtrol_Destroy(obj);
}
LRESULT WINAPI DarkMoonUI::zyCustomCtrol::zyCustomCtrol_WndProc(zyObject* obj, HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL* bHandle)
{
	if (uMsg == WM_NCDESTROY) {
		zyCustomCtrol* zyb = (zyCustomCtrol*)obj->getPtrData(L"this");
		zyb->OnNCDestroy();
	}
	if (uMsg == WM_ERASEBKGND) {
		zyCustomCtrol* zyb = (zyCustomCtrol*)obj->getPtrData(L"this");
		if (zyb->OnDrawBack(hWnd, (HDC)wParam)) {
			*bHandle = true;
			return 1;
		}
	}
	return zyCtrol::zyCtrol_WndProc(obj, hWnd, uMsg, wParam, lParam, bHandle);
}

void DarkMoonUI::zyCustomCtrol::OnNCDestroy() {

	LONG_PTR pBackImage = GetMember(L"pBackImage");
	if (pBackImage)
		SetMember(L"pBackImage", 0);

}
int DarkMoonUI::zyCustomCtrol::背景色(int 参数_背景色)
{
	int color = (int)GetMember(L"BackColor");
	if (参数_背景色 != 0) {
		SetMember(L"BackColor", 参数_背景色);
		重画();
	}
	return color;
}